package com.java.dp.copy;

/**
 * @Author lizhilong
 * @create 2019/12/2 15:42
 * @desc 原型模式
 */
public class CopyMain {

    public static void main(String[] args) throws CloneNotSupportedException {
        Student st1 = new Student();
        st1.setName("小明");
        st1.setAge(19);
        Subject subject = new Subject();
        subject.setName("语文");
        subject.setScore(88.9);
        st1.setSubject(subject);
        System.out.println("st1:"+st1.toString());

        Student st2 = (Student) st1.clone();
        System.out.println("st2:"+st2.toString());

        subject.setName("数学");
        System.out.println("------------------------------------------------");
        System.out.println("修改后st1:"+st1.toString());
        System.out.println("修改后st2:"+st2.toString());
    }
}
